home *** CD-ROM | disk | FTP | other *** search
/ Kellogg's Amérique / Kellogg's Amérique / super_quizz.swf / scripts / elements / BoutonQuizz.as < prev   
Text File  |  2020-08-04  |  2KB  |  87 lines

  1. package elements
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.events.Event;
  5.    import flash.events.MouseEvent;
  6.    
  7.    public class BoutonQuizz extends MovieClip
  8.    {
  9.        
  10.       
  11.       public var clicable:Boolean = true;
  12.       
  13.       private var targetFrame:int = 0;
  14.       
  15.       public var clicAction:Function;
  16.       
  17.       public var activated:Boolean = false;
  18.       
  19.       public function BoutonQuizz()
  20.       {
  21.          activated = false;
  22.          clicable = true;
  23.          targetFrame = 0;
  24.          super();
  25.          addFrameScript(0,frame1,1,frame2);
  26.          gotoAndStop(1);
  27.          buttonMode = true;
  28.          addEventListener(MouseEvent.MOUSE_OVER,_survole);
  29.          addEventListener(MouseEvent.MOUSE_DOWN,_bouton_clic);
  30.       }
  31.       
  32.       private function _survole(param1:MouseEvent) : void
  33.       {
  34.          targetFrame = 2;
  35.          addEventListener(Event.ENTER_FRAME,_framing);
  36.          removeEventListener(MouseEvent.MOUSE_OVER,_survole);
  37.          addEventListener(MouseEvent.MOUSE_OUT,_sort);
  38.       }
  39.       
  40.       function frame1() : *
  41.       {
  42.          stop();
  43.       }
  44.       
  45.       private function _sort(param1:MouseEvent) : void
  46.       {
  47.          targetFrame = 1;
  48.          addEventListener(Event.ENTER_FRAME,_framing);
  49.          addEventListener(MouseEvent.MOUSE_OVER,_survole);
  50.          removeEventListener(MouseEvent.MOUSE_OUT,_sort);
  51.       }
  52.       
  53.       function frame2() : *
  54.       {
  55.          stop();
  56.       }
  57.       
  58.       private function _framing(param1:Event) : void
  59.       {
  60.          if(targetFrame == 0)
  61.          {
  62.             return;
  63.          }
  64.          if(currentFrame == targetFrame)
  65.          {
  66.             removeEventListener(Event.ENTER_FRAME,_framing);
  67.          }
  68.          if(currentFrame > targetFrame)
  69.          {
  70.             prevFrame();
  71.          }
  72.          if(currentFrame < targetFrame)
  73.          {
  74.             nextFrame();
  75.          }
  76.       }
  77.       
  78.       private function _bouton_clic(param1:MouseEvent) : void
  79.       {
  80.          if(clicAction != null)
  81.          {
  82.             clicAction(int(name.substring(3)));
  83.          }
  84.       }
  85.    }
  86. }
  87.